package com.yiwei.hdb.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yiwei.hdb.R;
import com.yiwei.hdb.adapter.base.BaseRViewSubAdapter;
import com.yiwei.hdb.adapter.base.BaseViewHolder;
import com.yiwei.hdb.interfaces.OnRecyclerViewListener;
import com.yiwei.hdb.model.MessageModel;
import com.yiwei.hdb.util.RoundedBitmapUtils;

import java.util.List;


/**
 * 消息中心
 * Created by MasterDong on 16/4/12.
 */

public class MessageAdapterNew extends BaseRViewSubAdapter<MessageModel.DataList> {

    private static int GRAY = 0;
    private static int GRAY_DARK = 0;

    private OnRecyclerViewListener onRecyclerViewListener;

    public void setOnRecyclerViewListener(OnRecyclerViewListener onRecyclerViewListener) {
        this.onRecyclerViewListener = onRecyclerViewListener;
    }



    private Context mContext;
    private List<MessageModel.DataList> list;

    public MessageAdapterNew(Context context, List<MessageModel.DataList> list) {
        super(context,R.layout.item_message,list);
        this.list = list;
        this.mContext = context;
//        GRAY = ContextCompat.getColor(mContext, R.color.gray);
//        GRAY_DARK = ContextCompat.getColor(mContext, R.color.gray_dark);
    }

    @Override
    protected void convert(BaseViewHolder viewHoder, MessageModel.DataList item, final int position) {
        MessageModel.DataList model = item;

        TextView time=viewHoder.getTextView(R.id.txt_time);

        time.setText(model.getCreate_time_format());
        TextView title=viewHoder.getTextView(R.id.txt_title);
        title.setText(model.getTitle());
//        TextView date=viewHoder.getTextView(R.id.date);
        TextView content=viewHoder.getTextView(R.id.txt_content);
//        date.setText(model.getDate());
        content.setText(model.getContent());
//        ImageView icon = viewHoder.getImageView(R.id.icon);
//        RoundedBitmapUtils.setRoundedDrawable(mContext.getResources(),icon,R.mipmap.message_icon);
//        TextView see = viewHoder.getTextView(R.id.see);

//        if (Integer.parseInt(model.getRead_time()) <= 0) {
//            title.setTextColor(GRAY_DARK);
//            date.setTextColor(GRAY_DARK);
//            content.setTextColor(GRAY_DARK);
//           // title.setTextColor(GRAY_DARK);
//             see.setTextColor(GRAY_DARK);
//        } else {
//            title.setTextColor(GRAY);
//            date.setTextColor(GRAY);
//            content.setTextColor(GRAY);
//            //title.setTextColor(GRAY);
//            see.setTextColor(GRAY);
//        }


        View rootView = viewHoder.getView(R.id.layout_total);
        rootView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != onRecyclerViewListener) {
                    onRecyclerViewListener.onItemClick(list, position);
                }
            }
        });
        rootView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (null != onRecyclerViewListener) {
                    return onRecyclerViewListener.onItemLongClick(list, position);
                }
                return false;
            }
        });

    }






}

